package com.neusoft.oop;

public class OOPTestch6_ch7 {

	public static void main(String[] args) {
		//测试final关键字用法
		//testfinal();
		//重写以及父类指代子类
		test01();
		
		
		
	}
	
	/**
	 * 重写方法
	 */
	private static void test01() {
		//新建一个animal 对象
		Animal animal1= new Animal();
		animal1.eat();
		
		//新建一个bear 对象
		Bear bear1 = new Bear();
		bear1.eat();
		bear1.eat("banana");
		
		//新建一个黑熊对象
		BlackBear bBear1 = new BlackBear();
		bBear1.eat();
		
		//新建一个对象数组
		Animal[] animal = new Animal[5];
		animal[0] = new Mouse("white");
		animal[1]= new Tiger();
		animal[1].walkaround();
		animal[2] = new BlackBear();
		animal[3] = new Bear();
		animal[4] = new Animal();
		
		//遍历输出eat
		printEat(animal);
		boolean a = animal[2] instanceof BlackBear ;
		boolean b =animal[2] instanceof Bear;
		boolean c =animal[2] instanceof Animal;
		System.out.println("animal[2]是blackbear的对象"+a+b+c);
		
		System.out.println("boolea a 是object的子类"+animal[2] instanceof Object);
	}
	
	private static void printEat(Animal[] anArr) {
		//遍历数组
		for (Animal animal : anArr) {
			animal.eat();
		}
	}
	
	
	
	
	/**
	 * 测试final关键字的用法
	 */
	private static void testfinal() {
		Mouse mouse1 = new Mouse("blue");
	}

}
